package com.yida.wy.vote.controller;

import cn.hutool.core.bean.BeanUtil;
import com.yida.common.core.web.controller.BaseController;
import com.yida.common.core.web.domain.AjaxResult;
import com.yida.common.security.annotation.RequiresPermissions;
import com.yida.wy.vote.domain.dto.WyVoteTemplateDetailDTO;
import com.yida.wy.vote.service.IWyVoteTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 投票模板Controller
 *
 * @author lqq
 * @date 2023-03-10
 */
@Api(tags = "投票选项模板")
@RestController
@RequestMapping("/template")
public class WyVoteTemplateController extends BaseController {

	@Resource
	private IWyVoteTemplateService voteTemplateService;

	@ApiOperation("获取投票模板列详细信息")
	@RequiresPermissions("gwj:vote:e:template:query")
	@GetMapping(value = "/{voteId}")
	public AjaxResult getInfo(@PathVariable("voteId") Long voteId) {
		return AjaxResult.success(BeanUtil.copyProperties(voteTemplateService.selectVoteTemplateByVoteId(voteId), WyVoteTemplateDetailDTO.class));
	}
}
